package MeetingPoint;

import java.io.*;
import java.util.Arrays;
import java.util.Comparator;
public class Solution {
	public static void main(String[] args)  throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//BufferedReader br = new BufferedReader(new FileReader("data.txt"));
		String line = br.readLine();
		int N = Integer.parseInt(line);
		Point[] p1=new Point[N];
		double x=0,y=0;
		for(int i=0;i<=N-1;i++){
			line = br.readLine();
			String str[]=line.split(" ");
			x=(x+Integer.parseInt(str[0]))/(i+1);
			y=(y+Integer.parseInt(str[1]))/(i+1);
			p1[i]=new Point(Integer.parseInt(str[0]),Integer.parseInt(str[1]));
		}
		br.close();
		Arrays.sort(p1,xcompar);
		int indexx=Math.abs(Arrays.binarySearch(p1, new Point((int)x,0),xcompar));
		int l=1000>N?N:1000;
		Point[] L=new Point[l];
		//find cloest 1000 points to the heavy center.
		for (int i=0;i<=l-1;i++)L[i]=new Point(1000000000,1000000000);
		double min=9999999999999999.0;
		for (int i=indexx;i>=0&&Math.abs(p1[i].x-x)<min;i--){
			if(p1[i].Distance(x, y)<L[0].Distance(x, y)){
				int j;
				for(j=0;j<=l-2;j++){

					if(p1[i].Distance(x, y)<L[j+1].Distance(x, y)){
						L[j]=L[j+1];
					}
					else{
						break;
					}
				}
				L[j]=p1[i];
			}
		}
		for (int i=Math.min(indexx+1,N-1);i<=N-10&&Math.abs(p1[i].x-x)<min;i++){
			if(p1[i].Distance(x, y)<L[0].Distance(x, y)){
				int j;
				for(j=0;j<=l-2;j++){
					L[j]=L[j+1];
					if(p1[i].Distance(x, y)<L[j+1].Distance(x, y)){
						L[j]=L[j+1];
					}
					else{
						break;
					}
				}
				L[j]=p1[i];
			}
		}
		//compare them
		long result=Long.MAX_VALUE;
		for(int i=0;i<=l-1;i++){
			long temp=0;
			for(int k=0;k<=N-1;k++){
				temp+=p1[k].Distance2(L[i].x, L[i].y);
			}
			if(temp<result)result=temp;
		}
		System.out.println(result);



	}

	private static class Point{
		int x;
		int y;
		public Point (int x,int y){
			this.x=x;
			this.y=y;
		}

		public double Distance(double x,double y){
			return Math.sqrt((this.x-x)*(this.x-x)+(this.y-y)*(this.y-y));
		}
		public int Distance2(int x,int y){
			return Math.max(Math.abs(this.x-x),Math.abs(this.y-y));
		}
	}


	private static Comparator<Point> xcompar = new Comparator<Point>() { 
		@Override  
		public int compare(Point o1, Point o2) {  
			if(o1.x<o2.x){  
				return -1;  
			}  
			else if(o1.x>o2.x){  
				return 1;  
			}  
			return 0;  
		}  
	};

	private static Comparator<Point> ycompar = new Comparator<Point>() { 
		@Override  
		public int compare(Point o1, Point o2) {  
			if(o1.y<o2.y){  
				return -1;  
			}  
			else if(o1.y>o2.y){  
				return 1;  
			}  
			return 0;  
		}  
	};



}
